using System;
using System.Security.Cryptography;
using System.Text;

public class AESBase64Utils
{
    // Encryption algorithm
    private const string ALGO = "AES";

    private byte[] keyValue;

    /// <summary>
    /// Decrypts the encrypted data
    /// </summary>
    public string Decrypt(string encryptedData)
    {
        var key = GenerateKey();
        using (var aes = Aes.Create())
        {
            aes.Key = key;
            aes.Mode = CipherMode.ECB; // Java AES defaults to ECB
            aes.Padding = PaddingMode.PKCS7; // Java AES defaults to PKCS5 which is PKCS7 in .NET

            using (var decryptor = aes.CreateDecryptor())
            {
                byte[] decodedValue = Convert.FromBase64String(encryptedData);
                byte[] decValue = decryptor.TransformFinalBlock(decodedValue, 0, decodedValue.Length);
                string decryptedValue = Encoding.UTF8.GetString(decValue);
                return decryptedValue;
            }
        }
    }

    /// <summary>
    /// Generates the key
    /// </summary>
    private byte[] GenerateKey()
    {
        return keyValue;
    }

    public void SetKeyValue(byte[] keyValue)
    {
        this.keyValue = keyValue;
    }

    public static string Decrypt(string data, string secretKey)
    {
        // Create encryption/decryption class
        var aes = new AESBase64Utils();
        // Set encryption/decryption key
        aes.SetKeyValue(Encoding.UTF8.GetBytes(secretKey));
        // Decrypted string
        return aes.Decrypt(data);
    }
}